package cn.uce.cc.rest.control;

import cn.uce.base.ccos.WorkOrderVo;
import cn.uce.base.vo.FlowWorkBillVo;
import cn.uce.base.vo.WosWorkBillVo;
import cn.uce.cc.api.service.biz.ICcosWorkOrderBiz;
import cn.uce.web.common.base.BaseController;
import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;


 /**
   * 工单相关controller
   * @Author liupan
   * @Description
   * @Date  2020-06-30 15:45
   */
@Controller
@RequestMapping(value = "/ccos/workOrder")
public class CcosWorkOrderController extends BaseController {

    private Logger log = LoggerFactory.getLogger(CcosWorkOrderController.class);


    @Resource
    private ICcosWorkOrderBiz ccosWorkOrderBiz;


    /**
     * 新增工单接口
     * @param workOrderVo
     * @return
     */
    @RequestMapping(value = "/addWorkOrder", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> addWorkOrder(WorkOrderVo workOrderVo) {
        try {
            log.warn("addWorkOrderreuqert:"+ JSON.toJSONString(workOrderVo));
            String result = ccosWorkOrderBiz.addWorkOrder(workOrderVo);
            log.warn("addWorkOrderreturn:"+ JSON.toJSONString(result));
            return returnSuccess(result);
        } catch (Exception e) {
            log.warn("addWorkOrder",e);
        }
        return null;
    }

     /**
      * //运单号，查询工单历史记录
      * @return
      */
     @RequestMapping(value = "/getHistoryWorkOrder", method = RequestMethod.POST)
     @ResponseBody
     public Map<String,Object> getHistoryWorkOrder(WosWorkBillVo wosWorkBillVo){
         return returnSuccess(ccosWorkOrderBiz.getHistoryWorkOrder(wosWorkBillVo));
     }

     @RequestMapping(value = "/getDealRecords", method = RequestMethod.POST)
     @ResponseBody
     public Map<String,Object>  getDealRecords(FlowWorkBillVo flowWorkBillVo){
         return returnSuccess(ccosWorkOrderBiz.getDealRecords(flowWorkBillVo));
     }
}
